package com.naiterui.ehp.bs.agent.util;

import com.naiterui.ehp.bp.utils.encypt.MD5;
import com.naiterui.ehp.bp.utils.encypt.RSAUtil;
import com.naiterui.ehp.bp.utils.lang.ConfigUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * @author yiren
 * @since 2022/2/22
 */
@Slf4j
public class Tools {
	public static String getImagePath(String path) {
		if (path == null || "".equals(path)){
			return "";
		}
		return ConfigUtil.getString("ehp.domain.img") + path;
	}
	/**
	 * 获取环比
	 *
	 * @param today
	 * @param yesterday
	 * @return
	 */
	public static BigDecimal getQoq(Integer today, Integer yesterday) {
		if (yesterday == null || yesterday == 0) {
			return BigDecimal.valueOf(0.0);
		}
		return BigDecimal.valueOf((today - yesterday) * 100).divide(BigDecimal.valueOf(yesterday), 2,
				BigDecimal.ROUND_HALF_DOWN);
	}


	public static String nullToEmpty(String value) {
		return value == null ? "" : value;
	}

	public static void main(String[] args) {
		System.out.println(MD5.md5("333333v8MzeK1vKv"));
	}
}
